import 'package:baselib/utils/image_util.dart';
import 'package:baselib/widgets/comm_app_bar.dart';
import 'package:baselib/widgets/comm_password_textfield.dart';
import 'package:baselib/widgets/comm_textfield.dart';
import 'package:baselib/widgets/gradient_card_view.dart';
import 'package:baselib/widgets/inkwell_button.dart';
import 'package:baselib/widgets/nosize_app_bar.dart';
import 'package:baselib/widgets/simple_button.dart';
import 'package:baselib/widgets/xtcardview.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:framelib/utils/color_util.dart';
import 'package:framelib/utils/drawable_util.dart';
import 'package:framelib/utils/px_util.dart';
import 'package:framelib/utils/string_util.dart';
import 'package:framelib/widgets/main_gradient_button.dart';
import 'package:framelib/widgets/page_widget.dart';
import 'package:get/get.dart';
import 'package:module_business/module_comm/viewmodel/forget_password_view_model.dart';
import 'package:module_business/module_comm/viewmodel/login_email_view_model.dart';
import 'package:module_business/module_comm/viewmodel/register_view_model.dart';
/**
 * 忘记密码主页
 */
class ForgetPasswordPage extends GetWidget<ForgetPasswordViewModel> {
  @override
  Widget build(BuildContext context) {
    return PageWidget.build(
        builder: (ForgetPasswordViewModel model){
          return PageWidget.PageScaffoldWidget(
            isShowBg: true,
            appBar: CommAppBar(
              backgroundColor: ColorUtil.instance.color_transparent,
            ),
            body: SingleChildScrollView(
                child: Container(
                  width: PxUtil.instance.screenWidth,
                  height: PxUtil.instance.screenHeight-PxUtil.instance.statusBarHeight
                    -PxUtil.instance.appBarHeight,
                  padding: EdgeInsets.only(
                    left: PxUtil.instance.px_15,
                    right: PxUtil.instance.px_15,
                  ),
                  child: _buildMiddleContUi(model),
                )
            ),
          );
        }
    );
  }

  _buildMiddleContUi(ForgetPasswordViewModel model) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.center,
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        //标题
        Container(
          width: PxUtil.instance.screenWidth,
          alignment: Alignment.centerLeft,
          padding: EdgeInsets.only(
            left: PxUtil.instance.px_5
          ),
          child: ImagesUtil.loadAssetImage(
            DrawableUtil.instance.icon_Forget_the_password,
            height: PxUtil.instance.px_26,
            fit: BoxFit.fitHeight
          ),
        ),
        //账号
        GradientCardView(
          margin: EdgeInsets.only(
            top: PxUtil.instance.px_20,
          ),
          padding: EdgeInsets.only(
            left: PxUtil.instance.px_15,
            right: PxUtil.instance.px_15,
          ),
          height: PxUtil.instance.px_43,
          backGroundColor: ColorUtil.instance.color_2F3F71,
          child: Row(
            children: [
              Container(
                margin: EdgeInsets.only(
                    right: PxUtil.instance.px_15
                ),
                child: ImagesUtil.loadAssetImage(
                    DrawableUtil.instance.icon_login_email,
                    height: PxUtil.instance.px_16,
                    fit: BoxFit.fitHeight
                ),
              ),
              Expanded(child: CommTextField(
                defaultUnderlineColor: ColorUtil.instance.color_transparent,
                foucosUnderlineColor: ColorUtil.instance.color_transparent,
                lableText: StringUtil.instance.Please_enter_your_account_number,
                lableTextStyle: TextStyle(fontSize: PxUtil.instance.px_14,
                    color: ColorUtil.instance.color_878787),
                textStyle: TextStyle(fontSize: PxUtil.instance.px_14,
                    color: ColorUtil.instance.color_white),
                paddingBottm: PxUtil.instance.px_4,
                // inputFormatters: [WhitelistingTextInputFormatter(RegExp("[0-9a-zA-Z._@]"))],
                // keyboardType: TextInputType.phone,
                isShowDeleteMain: true,
                maxLength: 20,
                maxLines: 1,
                defaultCont: model?.account??'',
                textInputAction: TextInputAction.next,
                onChanged: (value)=>model?.inputChanged(value,0),
              ))
            ],
          )
        ),

        GradientCardView(
          margin: EdgeInsets.only(
            top: PxUtil.instance.px_26,
          ),
          padding: EdgeInsets.only(
            left: PxUtil.instance.px_15,
            right: PxUtil.instance.px_15,
          ),
          height: PxUtil.instance.px_43,
          backGroundColor: ColorUtil.instance.color_2F3F71,
          child: Row(
            children: [
              Container(
                margin: EdgeInsets.only(
                    left: PxUtil.instance.px_3,
                    right: PxUtil.instance.px_19
                ),
                child: ImagesUtil.loadAssetImage(
                    DrawableUtil.instance.icon_login_lock,
                    height: PxUtil.instance.px_16,
                    fit: BoxFit.fitHeight
                ),
              ),
              Expanded(child: CommPasswordTextField(
                defaultUnderlineColor: ColorUtil.instance.color_transparent,
                foucosUnderlineColor: ColorUtil.instance.color_transparent,
                lableText: StringUtil.instance.Please_enter_a_password,
                lableTextStyle: TextStyle(fontSize: PxUtil.instance.px_14,color: ColorUtil.instance.color_878787),
                textStyle: TextStyle(fontSize: PxUtil.instance.px_14,color: ColorUtil.instance.color_white),
                paddingBottm: PxUtil.instance.px_4,
                isShowEye: true,
                defaultCont: model?.password??'',
                inputFormatters: [FilteringTextInputFormatter.allow(RegExp("[0-9A-Za-z,.@]"))],
                onChanged: (value)=>model?.inputChanged(value,1),
              ))
            ],
          ),
        ),

        GradientCardView(
          margin: EdgeInsets.only(
            top: PxUtil.instance.px_26,
          ),
          padding: EdgeInsets.only(
            left: PxUtil.instance.px_15,
            right: PxUtil.instance.px_15,
          ),
          height: PxUtil.instance.px_43,
          backGroundColor: ColorUtil.instance.color_2F3F71,
          child: Row(
            children: [
              Container(
                margin: EdgeInsets.only(
                    left: PxUtil.instance.px_3,
                    right: PxUtil.instance.px_19
                ),
                child: ImagesUtil.loadAssetImage(
                    DrawableUtil.instance.icon_login_lock,
                    height: PxUtil.instance.px_16,
                    fit: BoxFit.fitHeight
                ),
              ),
              Expanded(child: CommPasswordTextField(
                defaultUnderlineColor: ColorUtil.instance.color_transparent,
                foucosUnderlineColor: ColorUtil.instance.color_transparent,
                lableText: StringUtil.instance.Please_enter_the_password_again,
                lableTextStyle: TextStyle(fontSize: PxUtil.instance.px_14,color: ColorUtil.instance.color_878787),
                textStyle: TextStyle(fontSize: PxUtil.instance.px_14,color: ColorUtil.instance.color_white),
                paddingBottm: PxUtil.instance.px_4,
                isShowEye: true,
                defaultCont: model?.okpassword??'',
                inputFormatters: [FilteringTextInputFormatter.allow(RegExp("[0-9A-Za-z,.@]"))],
                onChanged: (value)=>model?.inputChanged(value,2),
              ))
            ],
          ),
        ),

        //找回密码
        Container(
          margin: EdgeInsets.only(
            top: PxUtil.instance.px_53,
          ),
          child: MainGradientButton(
            onPressed: ()=>model.toFind(),
            isImg: true,
            imgPath: DrawableUtil.instance.icon_Continue,
            imgWidth: PxUtil.instance.px_80,
          ),
        ),
      ],
    );
  }

}
